home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 March / maximum-cd-2000-03.iso / Quake3 Game Source / Q3AGameSource.exe / Main / g_mem.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-18  |  776 b   |  42 lines

  1. // Copyright (C) 1999-2000 Id Software, Inc.
  2. //
  3. //
  4. // g_mem.c
  5. //
  6.  
  7.  
  8. #include "g_local.h"
  9.  
  10.  
  11. #define POOLSIZE    (256 * 1024)
  12.  
  13. static char        memoryPool[POOLSIZE];
  14. static int        allocPoint;
  15.  
  16. void *G_Alloc( int size ) {
  17.     char    *p;
  18.  
  19.     if ( g_debugAlloc.integer ) {
  20.         G_Printf( "G_Alloc of %i bytes (%i left)\n", size, POOLSIZE - allocPoint - ( ( size + 31 ) & ~31 ) );
  21.     }
  22.  
  23.     if ( allocPoint + size > POOLSIZE ) {
  24.         G_Error( "G_Alloc: failed on allocation of %u bytes\n", size );
  25.         return NULL;
  26.     }
  27.  
  28.     p = &memoryPool[allocPoint];
  29.  
  30.     allocPoint += ( size + 31 ) & ~31;
  31.  
  32.     return p;
  33. }
  34.  
  35. void G_InitMemory( void ) {
  36.     allocPoint = 0;
  37. }
  38.  
  39. void Svcmd_GameMem_f( void ) {
  40.     G_Printf( "Game memory status: %i out of %i bytes allocated\n", allocPoint, POOLSIZE );
  41. }
  42.